﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.WindowsAzure;

namespace BareWeb.FluentAzureDiagnostics.Tests
{
    [TestClass]
    public class DirectoriesTest
    {
        [TestMethod]
        public void WithDirectory_Adds()
        {
            var target = new DiagnosticsCapture(CloudStorageAccount.DevelopmentStorageAccount);

            var expected = 1;
            var actual = target.Default().WithDirectory(@"C:\logs", "andyslogs", 100).Configuration.Directories.DataSources.Count;

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void WithDirectory_AddsMany()
        {
            var target = new DiagnosticsCapture(CloudStorageAccount.DevelopmentStorageAccount);

            var expected = 3;
            var actual = target.Default()
                .WithDirectory(@"C:\logs1", "andyslogs1", 100)
                .WithDirectory(@"C:\logs2", "andyslogs2", 100)
                .WithDirectory(@"C:\logs3", "andyslogs3", 100)
                .Configuration.Directories.DataSources.Count;

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void DirectoriesScheduledTransfer_Reflected()
        {
            var target = new DiagnosticsCapture(CloudStorageAccount.DevelopmentStorageAccount);

            var expected = TimeSpan.FromDays(1337D);

            var actual = target.Default()
                .TransferDirectoriesEvery(expected)
                .Configuration.Directories.ScheduledTransferPeriod;

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void DirectoriesQuota_Reflected()
        {
            var target = new DiagnosticsCapture(CloudStorageAccount.DevelopmentStorageAccount);

            var expected = 1337;

            var actual = target.Default()
                .WithDirectoriesBufferQuotaInMBOf(expected)
                .Configuration.Directories.BufferQuotaInMB;

            Assert.AreEqual(expected, actual);
        }
    }
}
